﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Gao.Poker.App.Win;
using Gao.Poker.Domain;
using Gao.Poker.ViewModel;

namespace Gao.Poker.App.UserControls
{
    /// <summary>
    /// Interaction logic for CompetitionSetting.xaml
    /// </summary>
    public partial class CompetitionSetting : UserControl
    {
        private readonly CompetitionViewModel _viewModel;

        public CompetitionSetting()
        {
            InitializeComponent();
            _viewModel = new CompetitionViewModel{Message = OnMessage};
            DataContext = _viewModel;
            btnNew.Click += New_Click;
            btnApply.Click += Apply_Click;
            btnBuy.Click += Buy_Click;
        }

        private void Buy_Click(object sender, RoutedEventArgs e)
        {
            
        }

        private void Apply_Click(object sender, RoutedEventArgs e)
        {
            if (_viewModel.Competition == null || _viewModel.Competition.ID <= 0)
            {
                MessageBox.Show("请选择报名的比赛", "提示信息");
                return;
            }
            MemberWin win = new MemberWin();
            win.ViewModel = _viewModel;
            win.Competition = _viewModel.Competition;
            win.Show();
        }

        void New_Click(object sender, RoutedEventArgs e)
        {
            _viewModel.Competition = new Competition();
        }

        private void OnMessage(string msg)
        {
            MessageBox.Show(msg, "提示信息");
        }
    }
}
